package com.example.rbac.controller.restful;

import com.example.rbac.entity.TableField;
import com.example.rbac.entity.defefult.Result;
import com.example.rbac.service.TablesService;
import com.example.rbac.uitls.ResultUtil;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/api/TableField")
@RestController
public class TableFieldRestController {

    @Autowired
    private TablesService tablesService;

    @GetMapping("/getList")
    public Result getList(String tableName){
        List<TableField> list = Lists.newLinkedList();
        try {
            list = tablesService.showTable("role");
        }catch (Exception e){
            ResultUtil.erorr(500, "系统错误");
        }
        return ResultUtil.success(list);
    }
}
